﻿namespace Web.Control.WWW.Answers
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Text.RegularExpressions;
    using System.IO;
    using Lx.Web.Common.ControlsUI;
    using Lx.Web.Common.UI;
    using Model.WWW_WWW.Answers;
    using BLF.WWW_WWW.Answer;
    using System.Collections.Generic;

    public class Tags : BaseControl
    {
        /// <summary>
        /// 目标语言
        /// </summary>
        protected string Learn = "";
        /// <summary>
        /// 使用语言
        /// </summary>
        protected string BaseL = "";
        protected Repeater repPques;
        protected Repeater repLques;
        protected Repeater repWTags;
        protected Repeater repATags;
        protected List<QuestionModel> pquesList;
        protected List<QuestionModel> lquesList;
        protected List<AnswersTagModel> wTagsList;
        protected List<AnswersTagModel> aTagsList;
        protected override void OnLoad(EventArgs e)
        {
            if (Request.Cookies["italkiLearn"] == null)
            {
                HttpCookie llCookie = new HttpCookie("italkiLearn", "");
                Response.Cookies.Add(llCookie);
            }
            if (Request.Cookies["italkiSpeak"] == null)
            {
                HttpCookie blCookie = new HttpCookie("italkiSpeak", "");
                Response.Cookies.Add(blCookie);
            }
            if (!string.IsNullOrEmpty(Request["ll"]) && Request["ll"] != "")
            {
                Learn = Request["ll"];
                HttpCookie llCookie = new HttpCookie("italkiLearn", Learn);
                Response.Cookies.Add(llCookie);
            }
            else
            {
                Learn = Request.Cookies["italkiLearn"].Value;
            }
            if (!string.IsNullOrEmpty(Request["bl"]) && Request["bl"] != "")
            {
                BaseL = Request["bl"];
                HttpCookie blCookie = new HttpCookie("italkiSpeak", BaseL);
                Response.Cookies.Add(blCookie);
            }
            else
            {
                BaseL = "";
                HttpCookie blCookie = new HttpCookie("italkiSpeak", BaseL);
                Response.Cookies.Add(blCookie);
            }
            wTagsList = Answers.GetTagPuLa("", Learn, BaseL, out aTagsList, out pquesList, out lquesList);
            if (Learn != "" && Learn != "all" && BaseL != "" && BaseL != "all")
            {
                this.DynamicTitle = GetText("AS509", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
                this.DynamicKeywords = GetText("AS510", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
                this.DynamicDescription = GetText("AS511", new string[] { GetLanguageText(Learn), GetLanguageText(BaseL) });
            }
            else
            {
                this.DynamicTitle = GetText("AS506");
                this.DynamicKeywords = GetText("AS507");
                this.DynamicDescription = GetText("AS508");
            }
            if (repWTags != null)
            {
                repWTags.DataSource = wTagsList;
                repWTags.DataBind();
            }
            if (repATags != null)
            {
                repATags.DataSource = aTagsList;
                repATags.DataBind();
            }
            if (repPques != null)
            {
                repPques.DataSource = pquesList;
                repPques.DataBind();
            }
            if (repLques != null)
            {
                repLques.DataSource = lquesList;
                repLques.DataBind();
            }
        }
       
    }
}
